﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter26
{
    public class MainWindowViewModel
    {
        private List<Unit> catalogues = new List<Unit>();

        public List<Unit> Catalogues
        {
            get { return catalogues; }
        }


        public MainWindowViewModel()
        {
            catalogues.Add(new Unit { Num = 1, Title = "网络" });
            catalogues.Add(new Unit
            {
                Num = 2,
                Title = "WebClient 类",
                ChildCatalogues = new List<Unit>
                { 
                    new Unit { Num = 2.1, Title = "下载文件" }, 
                    new Unit { Num = 2.2, Title = "基本的 WebClient 示例" }, 
                    new Unit { Num = 2.3, Title = "上传文件" }, 
                },
            });
            catalogues.Add(new Unit
            {
                Num = 3,
                Title = "WebRequest 类和 WebResponse 类",
                ChildCatalogues = new List<Unit>
                {
                    new Unit { Num = 3.1, Title = "身份验证" }, 
                    new Unit { Num = 3.2, Title = "使用代理" }, 
                    new Unit { Num = 3.3, Title = "异步页面请求" }, 
                }
            });
            catalogues.Add(new Unit
            {
                Num = 4,
                Title = "把输出结果显示为 HTML 页面",
                ChildCatalogues = new List<Unit>
                {
                    new Unit { Num = 4.1, Title = "从应用程序中进行简单的 Web 浏览" }, 
                    new Unit { Num = 4.2, Title = "启动 Internet Explorer 实例" }, 
                    new Unit { Num = 4.3, Title = "给应用程序提供更多 IE 类型的功能" }, 
                }
            });
            catalogues.Add(new Unit { Num = 5, Title = "实用工具类" });
            catalogues.Add(new Unit { Num = 6, Title = "较低层的协议" });
        }

        public class Unit
        {
            public double Num { get; set; }
            public string Title { get; set; }
            public string Sample { get; set; }
            public List<Unit> ChildCatalogues { get; set; }
        }

        public override string ToString()
        {
            return "第26章 网络";
        }
    }
}
